home *** CD-ROM | disk | FTP | other *** search
/ PC Open 100 / PC Open 100 CD 2.bin / CD2 / PDF / Corsi / webdeveloper / lezione_4 / gestione_cancella.asp < prev    next >
Encoding:
Text File  |  2004-10-01  |  2.6 KB  |  134 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2.  
  3. <html>
  4. <head>
  5.     <title>Gestione foto di Mario Rossi</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <h1>Gestione foto</h1>
  11.  
  12.  
  13. <%
  14.  
  15. Const adOpenForwardOnly = 0
  16. Const adLockReadOnly = 1
  17.  
  18. Dim contatore
  19. Dim sql1,sql2
  20. Dim conn, rs
  21. Dim pagNum
  22. Dim pagSize
  23. Dim i,j
  24.  
  25. pagSize = 2
  26.  
  27. Set conn = Server.CreateObject("ADODB.Connection")
  28. conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/foto2.mdb")
  29.  
  30. sql1 = "SELECT count(nome) AS contatore FROM Foto"
  31. sql2 = "SELECT * FROM Foto ORDER BY Data DESC"
  32.  
  33. Set rs = Server.CreateObject("ADODB.RecordSet")
  34. rs.Open sql1, conn, adOpenForwardOnly, adLockReadOnly
  35.  
  36. contatore = rs("contatore")
  37.  
  38. rs.Close()
  39.  
  40.  
  41. 'Estrae il numero di pagina
  42. pagNum = cint(request.QueryString("pag"))
  43. If pagNum = 0 Then pagNum = 1
  44.  
  45. 'Imposta la dimensione della pagina (il numero massimo di elementi da far comparire per ogni pagina)
  46. rs.PageSize = pagSize
  47.  
  48. rs.Open sql2, conn, 3, adLockReadOnly
  49.  
  50. %>
  51.  
  52. Foto presenti nella base di dati: <%=contatore%><br><br>
  53. Inserisci una <a href="inseriscifoto.asp">nuova foto</a>
  54. <%
  55.  
  56.  
  57. rs.AbsolutePage = pagNum
  58.  
  59. for i = 1 to pagSize
  60.  
  61.     if not rs.EOF Then
  62.  
  63.         if i mod 2 = 0 then
  64.             strColor="#3333CC"
  65.         else
  66.             strColor="#FF0033"
  67.         end if
  68.  
  69. %>
  70.  
  71. <li>
  72.     <a style="color:<%=strColor%>" href="../../../../../PDF/Corsi/webdeveloper/lezione_4/dettagliofoto.asp?nome=<%=rs("Nome")%>"><%=rs("Titolo")%>, scattata a <%=rs("Luogo")%></a>
  73.     [<a href="modificafoto.asp?nome=<%=rs("nome")%>">modifica</a>]
  74.     [<a onclick="javascript:return confirm('Cancellare la foto selezionata ?')" href="eliminafoto_risposta.asp?nome=<%=rs("nome")%>">elimina</a>]
  75. </li>
  76.  
  77. <%
  78.         rs.movenext
  79.  
  80.     Else
  81.  
  82.         Exit For
  83.  
  84.     End If
  85.  
  86.  
  87. next
  88.  
  89. %>
  90.  
  91. <br><hr><br>
  92.  
  93. <div align="left">
  94.  
  95. <%
  96.     If pagNum > 1 Then
  97. %>
  98.     <a href="../../../../../PDF/Corsi/webdeveloper/lezione_4/<%=request.ServerVariables("PATH_INFO")%>?pag=<%=pagNum -1%><%=strTipo%>">«</a>
  99. <%
  100.     End If
  101. %>
  102.  
  103. <% for j = 1 to rs.PageCount %>
  104.     <% if j = pagNum then %>
  105.         <%=j%>
  106.     <% else %>
  107.         <a href="../../../../../PDF/Corsi/webdeveloper/lezione_4/<%=request.ServerVariables("PATH_INFO")%>?pag=<%=j%><%=strTipo%>"><%=j%></a>
  108.     <% end if %>
  109. <% next %>
  110.  
  111. <%
  112.     If pagNum < rs.PageCount Then
  113. %>
  114.     <a href="../../../../../PDF/Corsi/webdeveloper/lezione_4/<%=request.ServerVariables("PATH_INFO")%>?pag=<%=pagNum+1%><%=strTipo%>">»</a>
  115. <%
  116.     End If
  117. %>
  118.  
  119. </div>
  120.  
  121. <%
  122. rs.close
  123. set rs = nothing
  124. conn.close
  125. set conn = nothing
  126.  
  127. %>
  128.  
  129. </ul>
  130.  
  131. </body>
  132. </html>
  133.  
  134.